<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>The iFiction Record</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'The iFiction Record' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">if</a></li><li><a href="index.html#2">Chapter 2: Bibliographic Data</a></li><li><b>The iFiction Record</b></li></ul></div>
<p class="purpose">To write the iFiction record for the work of IF compiled.</p>

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>The format of this file is exactly specified by the Treaty of Babel.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">iFiction::write_ifiction_record</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">iFiction::write_ifiction_record</span></span>:<br/>Release Instructions - <a href="2-ri.html#SP9_1">&#167;9.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">release_instructions</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rel</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;ifindex version=\"1.0\" "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"xmlns=\"http:</span><span class="comment-syntax">babel.ifarchive.org/protocol/iFiction/\"&gt;\n"); INDENT;</span>
<span class="string-syntax">    WRITE("</span><span class="function-syntax">&lt;story&gt;</span><span class="plain-syntax">\</span><span class="identifier-syntax">n</span><span class="string-syntax">"); INDENT;</span>
<span class="string-syntax">    zbyte *header = rel-&gt;existing_story_header;</span>
<span class="string-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-tir.html#SP1_1" class="named-paragraph-link"><span class="named-paragraph">Write the body of the iFiction record</span><span class="named-paragraph-number">1.1</span></a></span><span class="string-syntax">;</span>
<span class="string-syntax">    OUTDENT; WRITE("</span><span class="function-syntax">&lt;/story&gt;</span><span class="plain-syntax">\</span><span class="identifier-syntax">n</span><span class="string-syntax">");</span>
<span class="string-syntax">    OUTDENT; WRITE("</span><span class="function-syntax">&lt;/ifindex&gt;</span><span class="plain-syntax">\</span><span class="identifier-syntax">n</span><span class="string-syntax">");</span>
<span class="string-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP1_1" class="paragraph-anchor"></a><b>&#167;1.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Write the body of the iFiction record</span><span class="named-paragraph-number">1.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">story_format</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TargetVMs::get_iFiction_format</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::vm</span><span class="plain-syntax">());</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-tir.html#SP1_1_1" class="named-paragraph-link"><span class="named-paragraph">Write the identification tag of the iFiction record</span><span class="named-paragraph-number">1.1.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-tir.html#SP1_1_2" class="named-paragraph-link"><span class="named-paragraph">Write the bibliographic tag of the iFiction record</span><span class="named-paragraph-number">1.1.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">NUMBER_CREATED</span><span class="plain-syntax">(</span><span class="reserved-syntax">auxiliary_file</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="2-tir.html#SP1_1_3" class="named-paragraph-link"><span class="named-paragraph">Write the resources tag of the iFiction record</span><span class="named-paragraph-number">1.1.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rel</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">release_cover</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="2-tir.html#SP1_1_4" class="named-paragraph-link"><span class="named-paragraph">Write the cover tag of the iFiction record</span><span class="named-paragraph-number">1.1.4</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-tir.html#SP1_1_5" class="named-paragraph-link"><span class="named-paragraph">Write the releases tag of the iFiction record</span><span class="named-paragraph-number">1.1.5</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-tir.html#SP1_1_6" class="named-paragraph-link"><span class="named-paragraph">Write the colophon tag of the iFiction record</span><span class="named-paragraph-number">1.1.6</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;%S&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_format</span><span class="plain-syntax">); </span><span class="identifier-syntax">INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-tir.html#SP1_1_7" class="named-paragraph-link"><span class="named-paragraph">Write the format-specific tag of the iFiction record</span><span class="named-paragraph-number">1.1.7</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/%S&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_format</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-tir.html#SP1">&#167;1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP1_1_1" class="paragraph-anchor"></a><b>&#167;1.1.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Write the identification tag of the iFiction record</span><span class="named-paragraph-number">1.1.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;identification&gt;\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;ifid&gt;%S&lt;/ifid&gt;\n"</span><span class="plain-syntax">, </span><a href="2-bd.html#SP11" class="function-link"><span class="function-syntax">BibliographicData::read_uuid</span></a><span class="plain-syntax">());</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Task::wraps_existing_storyfile</span><span class="plain-syntax">()) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;ifid&gt;ZCODE-%d-%c%c%c%c%c%c"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">header</span><span class="plain-syntax">[2]*256+</span><span class="identifier-syntax">header</span><span class="plain-syntax">[3],</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x12</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x13</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x14</span><span class="plain-syntax">],</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x15</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x16</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x17</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x12</span><span class="plain-syntax">] != </span><span class="character-syntax">'8'</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">Characters::isdigit</span><span class="plain-syntax">(</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x12</span><span class="plain-syntax">])))</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"-%04x"</span><span class="plain-syntax">, </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x1c</span><span class="plain-syntax">]*256 + </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x1d</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/ifid&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;format&gt;%S&lt;/format&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_format</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/identification&gt;\n"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-tir.html#SP1_1">&#167;1.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP1_1_2" class="paragraph-anchor"></a><b>&#167;1.1.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Write the bibliographic tag of the iFiction record</span><span class="named-paragraph-number">1.1.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;bibliographic&gt;\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;title&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-tir.html#SP2" class="function-link"><span class="function-syntax">iFiction::write_var_to_XML</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_title_VAR</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"Untitled"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/title&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;author&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-tir.html#SP2" class="function-link"><span class="function-syntax">iFiction::write_var_to_XML</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_author_VAR</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"Anonymous"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/author&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;headline&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-tir.html#SP2" class="function-link"><span class="function-syntax">iFiction::write_var_to_XML</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_headline_VAR</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"An Interactive Fiction"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/headline&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;genre&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-tir.html#SP2" class="function-link"><span class="function-syntax">iFiction::write_var_to_XML</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_genre_VAR</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"Fiction"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/genre&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;firstpublished&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-tir.html#SP2" class="function-link"><span class="function-syntax">iFiction::write_var_to_XML</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_creation_year_VAR</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%d"</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_year</span><span class="plain-syntax">)+1900);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/firstpublished&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">VariableSubjects::has_initial_value_set</span><span class="plain-syntax">(</span><span class="identifier-syntax">story_description_VAR</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;description&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="2-tir.html#SP2" class="function-link"><span class="function-syntax">iFiction::write_var_to_XML</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_description_VAR</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/description&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;language&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Languages::write_ISO_code</span><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">Projects::get_language_of_play</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::project</span><span class="plain-syntax">()));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/language&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;group&gt;Inform&lt;/group&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">episode_number</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;seriesnumber&gt;%d&lt;/seriesnumber&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">episode_number</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;series&gt;%w&lt;/series&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">series_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/bibliographic&gt;\n"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-tir.html#SP1_1">&#167;1.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP1_1_3" class="paragraph-anchor"></a><b>&#167;1.1.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Write the resources tag of the iFiction record</span><span class="named-paragraph-number">1.1.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">auxiliary_file</span><span class="plain-syntax"> *</span><span class="identifier-syntax">af</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;resources&gt;\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">af</span><span class="plain-syntax">, </span><span class="reserved-syntax">auxiliary_file</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;auxiliary&gt;\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;leafname&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Filenames::to_text_relative</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">af</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name_of_original_file</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Projects::materials_path</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::project</span><span class="plain-syntax">()));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HTML::write_xml_safe_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">rel</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/leafname&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">af</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">brief_description</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;description&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">HTML::write_xml_safe_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">af</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">brief_description</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/description&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/auxiliary&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/resources&gt;\n"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-tir.html#SP1_1">&#167;1.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP1_1_4" class="paragraph-anchor"></a><b>&#167;1.1.4. </b>The <span class="extract"><span class="extract-syntax">&lt;description&gt;</span></span> key here was added in version 8 of the Treaty of Babel,
in February 2014.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Write the cover tag of the iFiction record</span><span class="named-paragraph-number">1.1.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;cover&gt;\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;format&gt;%s&lt;/format&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">rel</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cover_art_format</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;height&gt;%d&lt;/height&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">rel</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">height</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;width&gt;%d&lt;/width&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">rel</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">width</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rel</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cover_alt_text</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Word::dequote</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cover_alt_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;description&gt;%N&lt;/description&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">rel</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cover_alt_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;description&gt;%w&lt;/description&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">Figures::description_of_cover_art</span><span class="plain-syntax">());</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/cover&gt;\n"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-tir.html#SP1_1">&#167;1.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP1_1_5" class="paragraph-anchor"></a><b>&#167;1.1.5. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Write the releases tag of the iFiction record</span><span class="named-paragraph-number">1.1.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;releases&gt;\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;attached&gt;\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;release&gt;\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Task::wraps_existing_storyfile</span><span class="plain-syntax">()) </span><span class="named-paragraph-container code-font"><a href="2-tir.html#SP1_1_5_1" class="named-paragraph-link"><span class="named-paragraph">Write release data for an existing story file</span><span class="named-paragraph-number">1.1.5.1</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-tir.html#SP1_1_5_2" class="named-paragraph-link"><span class="named-paragraph">Write release data for an Inform 7 project</span><span class="named-paragraph-number">1.1.5.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/release&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/attached&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/releases&gt;\n"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-tir.html#SP1_1">&#167;1.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP1_1_5_1" class="paragraph-anchor"></a><b>&#167;1.1.5.1. </b>ZILCH was Infocom's in-house compiler of Z-machine story files, and prior
to Inform the only one to exist. Inform differs from it in using the last four
bytes of the header to store its own version number.
</p>

<p class="commentary">(The following code will be incorrect on 1 January 2080.)
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Write release data for an existing story file</span><span class="named-paragraph-number">1.1.5.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;releasedate&gt;%s%c%c-%c%c-%c%c&lt;/releasedate&gt;\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        ((</span><span class="identifier-syntax">Characters::isdigit</span><span class="plain-syntax">(</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x12</span><span class="plain-syntax">])) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x12</span><span class="plain-syntax">] != </span><span class="character-syntax">'8'</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x12</span><span class="plain-syntax">] != </span><span class="character-syntax">'9'</span><span class="plain-syntax">))?</span><span class="string-syntax">"20"</span><span class="plain-syntax">:</span><span class="string-syntax">"19"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x12</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x13</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x14</span><span class="plain-syntax">],</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x15</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x16</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x17</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;version&gt;%d&lt;/version&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">header</span><span class="plain-syntax">[2]*256+</span><span class="identifier-syntax">header</span><span class="plain-syntax">[3]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Characters::isdigit</span><span class="plain-syntax">(</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3c</span><span class="plain-syntax">])) &amp;&amp;</span>
<span class="plain-syntax">        ((</span><span class="identifier-syntax">Characters::isdigit</span><span class="plain-syntax">(</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3d</span><span class="plain-syntax">])) || (</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3d</span><span class="plain-syntax">] == </span><span class="character-syntax">'.'</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">Characters::isdigit</span><span class="plain-syntax">(</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3e</span><span class="plain-syntax">])) &amp;&amp; (</span><span class="identifier-syntax">Characters::isdigit</span><span class="plain-syntax">(</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3f</span><span class="plain-syntax">]))) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3d</span><span class="plain-syntax">] == </span><span class="character-syntax">'.'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compiler&gt;Inform 6&lt;/compiler&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compilerversion&gt;%c%c%c%c&lt;/compilerversion&gt;\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3c</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3d</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3e</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3f</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compiler&gt;Inform 1-5&lt;/compiler&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compilerversion&gt;%c%c%c%c&lt;/compilerversion&gt;\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3c</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3d</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3e</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3f</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compiler&gt;ZILCH&lt;/compiler&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compilerversion&gt;%d&lt;/compilerversion&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x00</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-tir.html#SP1_1_5">&#167;1.1.5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP1_1_5_2" class="paragraph-anchor"></a><b>&#167;1.1.5.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Write release data for an Inform 7 project</span><span class="named-paragraph-number">1.1.5.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;releasedate&gt;%04d-%02d-%02d&lt;/releasedate&gt;\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_year</span><span class="plain-syntax">)+1900, (</span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_mon</span><span class="plain-syntax">)+1, </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_mday</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">story_release_number_VAR</span><span class="plain-syntax"> != </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">VariableSubjects::has_initial_value_set</span><span class="plain-syntax">(</span><span class="identifier-syntax">story_release_number_VAR</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;version&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="2-tir.html#SP2" class="function-link"><span class="function-syntax">iFiction::write_var_to_XML</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_release_number_VAR</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/version&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;version&gt;1&lt;/version&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compiler&gt;Inform 7&lt;/compiler&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compilerversion&gt;%B (build %B)&lt;/compilerversion&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-tir.html#SP1_1_5">&#167;1.1.5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP1_1_6" class="paragraph-anchor"></a><b>&#167;1.1.6. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Write the colophon tag of the iFiction record</span><span class="named-paragraph-number">1.1.6</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;colophon&gt;\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;generator&gt;Inform 7&lt;/generator&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;generatorversion&gt;%B (build %B)&lt;/generatorversion&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;originated&gt;20%02d-%02d-%02d&lt;/originated&gt;\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_year</span><span class="plain-syntax">)-100, (</span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_mon</span><span class="plain-syntax">)+1, </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_mday</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/colophon&gt;\n"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-tir.html#SP1_1">&#167;1.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP1_1_7" class="paragraph-anchor"></a><b>&#167;1.1.7. </b>ZIL was Infocom's in-house language, a variant of MDL which in turn resembled
LISP.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Write the format-specific tag of the iFiction record</span><span class="named-paragraph-number">1.1.7</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Task::wraps_existing_storyfile</span><span class="plain-syntax">()) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;serial&gt;%c%c%c%c%c%c&lt;/serial&gt;\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x12</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x13</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x14</span><span class="plain-syntax">],</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x15</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x16</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x17</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;release&gt;%d&lt;/release&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">header</span><span class="plain-syntax">[2]*256+</span><span class="identifier-syntax">header</span><span class="plain-syntax">[3]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;checksum&gt;%04x&lt;/checksum&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x1c</span><span class="plain-syntax">]*256 + </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x1d</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Characters::isdigit</span><span class="plain-syntax">(</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3c</span><span class="plain-syntax">])) &amp;&amp;</span>
<span class="plain-syntax">            ((</span><span class="identifier-syntax">Characters::isdigit</span><span class="plain-syntax">(</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3d</span><span class="plain-syntax">])) || (</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3d</span><span class="plain-syntax">] == </span><span class="character-syntax">'.'</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">Characters::isdigit</span><span class="plain-syntax">(</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3e</span><span class="plain-syntax">])) &amp;&amp; (</span><span class="identifier-syntax">Characters::isdigit</span><span class="plain-syntax">(</span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3f</span><span class="plain-syntax">]))) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compiler&gt;Inform v%c%c%c%c&lt;/compiler&gt;\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3c</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3d</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3e</span><span class="plain-syntax">], </span><span class="identifier-syntax">header</span><span class="plain-syntax">[</span><span class="constant-syntax">0x3f</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compiler&gt;Infocom ZIL&lt;/compiler&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;serial&gt;%02d%02d%02d&lt;/serial&gt;\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_year</span><span class="plain-syntax">)-100, (</span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_mon</span><span class="plain-syntax">)+1, </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_mday</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">story_release_number_VAR</span><span class="plain-syntax"> != </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">VariableSubjects::has_initial_value_set</span><span class="plain-syntax">(</span><span class="identifier-syntax">story_release_number_VAR</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;release&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><a href="2-tir.html#SP2" class="function-link"><span class="function-syntax">iFiction::write_var_to_XML</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">story_release_number_VAR</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;/release&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;release&gt;1&lt;/release&gt;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;compiler&gt;Inform %B (build %B)&lt;/compiler&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rel</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">release_cover</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;coverpicture&gt;%d&lt;/coverpicture&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">rel</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cover_picture_number</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-tir.html#SP1_1">&#167;1.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">iFiction::write_var_to_XML</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">iFiction::write_var_to_XML</span></span>:<br/><a href="2-tir.html#SP1_1_2">&#167;1.1.2</a>, <a href="2-tir.html#SP1_1_5_2">&#167;1.1.5.2</a>, <a href="2-tir.html#SP1_1_7">&#167;1.1.7</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="identifier-syntax">nonlocal_variable</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nlv</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">NonlocalVariables::initial_value_as_plain_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">nlv</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">nlv</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">VariableSubjects::has_initial_value_set</span><span class="plain-syntax">(</span><span class="identifier-syntax">nlv</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">val</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">NonlocalVariables::substitute_constants</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">VariableSubjects::get_initial_value</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">nlv</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NonlocalVariables::kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">nlv</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Node::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">val</span><span class="plain-syntax">, </span><span class="identifier-syntax">UNKNOWN_NT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_number</span><span class="plain-syntax">)) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_number</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">inter_pair</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CompileValues::constant_to_pair</span><span class="plain-syntax">(</span><span class="identifier-syntax">val</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterValuePairs::to_number</span><span class="plain-syntax">(</span><span class="identifier-syntax">N</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">val</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">w1</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><a href="2-bd.html#SP12" class="function-link"><span class="function-syntax">BibliographicData::compile_bibliographic_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">Lexer::word_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">w1</span><span class="plain-syntax">), </span><span class="constant-syntax">XML_BIBTEXT_MODE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="2-ri.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-im.html">1</a></li><li class="progresscurrentchapter">2</li><li class="progresssection"><a href="2-bd.html">bd</a></li><li class="progresssection"><a href="2-ri.html">ri</a></li><li class="progresscurrent">tir</li><li class="progresssection"><a href="2-tbf.html">tbf</a></li><li class="progresschapter"><a href="3-sm.html">3</a></li><li class="progresschapter"><a href="4-ap.html">4</a></li><li class="progresschapter"><a href="5-pp.html">5</a></li><li class="progresschapter"><a href="6-dlg.html">6</a></li><li class="progressnext"><a href="2-tbf.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

